form.input-group(id='URLSubmit' name='URLSubmit')
    input#story-url.big-text-field.field-responsive.form-control(placeholder='Paste your link here', name='link', type='url', required, autofocus)
    span.input-group-btn
        button#preliminary-story-submit.btn.btn-bigger.btn-primary.btn-responsive(type='submit') Submit
.spacer

    script.
      $('#story-url').on('keypress', function(e) {
        if (e.keyCode === 13) {
          $('#preliminary-story-submit').click();
        }
      });
      function preliminaryStorySubmit(e) {
        if (!$('#URLSubmit')[0].checkValidity()) {
          return null;
        }
        e.preventDefault();

          var storyURL = $('#story-url').val();
          $('#preliminary-story-submit').attr('disabled', 'disabled');

          $.post('/stories/preliminary',
          {
              data: {
                  url: storyURL
              }
          })
          .fail(function (xhr, textStatus, errorThrown) {
              $('#preliminary-story-submit').attr('disabled', false);
          })
          .done(function (data, textStatus, xhr) {
              if (data.alreadyPosted) {
                  window.location = data.storyURL;
              } else {
                  window.location = '/stories/submit/new-story?url=' +
                  encodeURIComponent(data.storyURL) +
                  '&title=' + encodeURIComponent(data.storyTitle) +
                  '&image=' + encodeURIComponent(data.storyImage) +
                  '&description=' + encodeURIComponent(data.storyMetaDescription);
              }
          });
      }

      $('#preliminary-story-submit').on('click', preliminaryStorySubmit);

      arr = $( "h3 input:checked" )
        .map(function() {
          return this.id;
        })
        .get()
        .join('&');
